{
 "cells": [
  {
   "metadata": {
    "collapsed": true
   },
   "cell_type": "markdown",
   "source": [
    "#### Chain的基本概念\n",
    "    Chain：链，用于将多个组件(提示模板、LLM模型、记忆、工具等)连接起来，形成可服用的工作流，完成复杂任务。\n",
    "    Chain的核心思想是通过组合不同的模块化单元，实现比单一组件更强大的功能。\n",
    "    比如：\n",
    "        将LLM与Prompt Template(提示模板)结合\n",
    "        将LLM与输出解析器结合\n",
    "        将LLM与外部数据结合，例如问答\n",
    "        将LLM与长期记忆结合，例如历史聊天记录\n",
    "        将第一个LLM的输出作为第二个LLM的输入，...，将多个LLM按顺序结合在一起"
   ],
   "id": "47d1e89e32f99bcb"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "#### LCEL及其基本构成\n",
    "    使用LCEL，可以构造出结构最简单的Chain。\n",
    "    LangChain表达式语言(LCEL,LangChain Expression Language)是一种声明式方法，可以轻松将多个组件链接成AI工作流。\n",
    "    它通过Python原生操作符(如管道符|)将组件连接成可执行流程，显著简化了AI应用的开发。\n",
    "    LECL的基本构成：提示(Prompt) + 模型(Model) + 输出解析器(OuputParser)\n",
    "    既：\n",
    "        chain = prompt | model | output_parser\n",
    "        chain.invoke({\"input\":\"What's your name?\"})"
   ],
   "id": "d8d53feaf0ac573c"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
